package com.piece.module.spider.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;

@Data
@Entity
@NoArgsConstructor
@Table(name = "sp_flow")
@ApiModel(value = "节点消息表:sp_flow")
public class SpiderFlow {

    @Id
    @Column(name = "id", length = 11)
    @ApiModelProperty(value = "主键")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "cron")
    @ApiModelProperty(value = "定时任务表达式")
    private String cron;

    @Column(name = "name")
    @ApiModelProperty(value = "爬虫定义名称")
    private String name;

    @Column(name = "xml")
    @ApiModelProperty(value = "xml流程图")
    private String xml;

    @Column(name = "xml_file_path")
    @ApiModelProperty(value = "xml流程图存储地址")
    private String xmlFilePath;

    @Column(name = "enabled")
    @ApiModelProperty(value = "运行状态")
    private String enabled;

    @Column(name = "create_date")
    @ApiModelProperty(value = "创建日期")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createDate;

    @Column(name = "last_execute_time")
    @ApiModelProperty(value = "上次执行时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date lastExecuteTime;

    @Column(name = "next_execute_time")
    @ApiModelProperty(value = "下次执行时间")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date nextExecuteTime;

    @Column(name = "execute_count")
    @ApiModelProperty(value = "流程定义主键")
    private Integer executeCount;

    @Transient
    private Integer running;
}
